﻿param($domainController,$zoneName,$csvDirectory)
Import-Module DnsServer
Import-Module ActiveDirectory

$executionTime=(Get-Date).GetDateTimeFormats("u").Replace(":","")
$csvPath="$csvDirectory\dns_"+$zoneName.Replace(".","_")+"_"+$executionTime+".csv"
Get-DnsServerResourceRecord -ComputerName $domainController  -ZoneName $zoneName | select DistinguishedName,HostName,RecordClass,RecordType,TimeStamp,TimeToLive,@{Expression={$_.RecordData.IPv4Address};Label="IPv4Address"},@{Expression={$_.RecordData.HostNameAlias};Label="HostNameAlias"} | Export-Csv -Path $csvPath -NoTypeInformation